home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13251 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  56 lines

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: extern func() declaration?
  5. Date: Fri, 05 Apr 96 14:49:05 GMT
  6. Organization: none
  7. Message-ID: <828715745snz@genesis.demon.co.uk>
  8. References: <316436C5.413E@micromedia.on.ca>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <316436C5.413E@micromedia.on.ca>
  15.            rsteadma@micromedia.on.ca "Richard Steadman" writes:
  16.  
  17. >Hello. This is just a minor point, but I couldn't find the
  18. >answer in the FAQ:
  19. >
  20. >What's the difference between
  21. >
  22. >        extern int func(void);
  23. >
  24. >and
  25. >
  26. >        int func(void);
  27.  
  28. There is no difference at all. A function declaration defaults to external
  29. linkage unless you explicitly make it static so whether you use extern
  30. or not is simply a style issue. extern can make a difference when declaring
  31. objects rather then functions e.g. if you write:
  32.  
  33.     int i;
  34.  
  35. then i is guaranteed to be defined (i.e. space allocated), barring errors
  36. elsewhere, in the current translation unit whereas if you write:
  37.  
  38.     extern int i;
  39.  
  40. there is no such guarantee either way. There is nothing equivalent for
  41. functions because a function is defined whenever you give it a body e.g.
  42.  
  43. extern int main(void)
  44.  
  45. {
  46.     return 0;
  47. }
  48.  
  49. is a perfectly good definition of main.
  50.  
  51. -- 
  52. -----------------------------------------
  53. Lawrence Kirby | fred@genesis.demon.co.uk
  54. Wilts, England | 70734.126@compuserve.com
  55. -----------------------------------------
  56.